#ifndef __CHAT_MEMBER_HXX__
#define __CHAT_MEMBER_HXX__

/**
 * ChatMember represents a chatting member, keeping all info relevant to it
 */
#include <winsock2.h>	// sockaddr_in
#include "mydll.h"
#include "mytypes.h"
#include "taskdefs.h"

class AudioPlayer;
class TcpSocket;
class FileLog;

class EXPORT ChatMember
{
public:
	typedef enum
	{
		MEM_LEVEL_UNDEFINED,
		/**
		 * The ones not to talk to.
		 */
		MEM_LEVEL_NO_LEVEL,

		/**
		 * The one to talk to
		 */
		MEM_LEVEL_COMMON_LEVEL,

		/**
		 * The one Who is with more privilege than common member,who can add or delete
		 * other common member.
		 */
		MEM_LEVEL_SUPPER_VELEL,

		/**
		 * The one who initiate the group chatting,with the authority with supper level, plus
		 * the authority to authorize or deprive supper level privileges
		 */
		MEM_LEVEL_ADMIN_LEVEL

		/**
		 * Note:no matter what privilege a member has, he can always remove member from
		 * his own chatting list
		 */
	}tMemLevel;
	/**
	 * brief	:	constructor
	 * @param	:	sockaddr_in:the udp sockaddr created with the host and the certain udp port for convinence to access
	 */
	ChatMember(tUInt32 userid,string username,string host,tUInt32 udp_port,tMemLevel level,FileLog* filelog);

	/**
	 * brief	:	destructor
	 */
	~ChatMember();

	void SetMemberLevel(tMemLevel level);

	tUInt32		GetMemId(void) const;
	tUInt32		GetMemPort(void) const;
	tMemLevel	GetMemLevel(void) const;

	const string&		GetMemHost(void) const;
	const string&		GetMemName(void) const;
	const sockaddr_in*	GetSockaddr(void) const;

	AudioPlayer*		GetPlayer(void) const;

private:
	/**
	 * @brief	:	Create the sockaddr_in struct for a given host and port
	 * @return	:	If successful returns the pointer to the object created, or NULL
	 */
	sockaddr_in* CreateSockaddrIn(string host, tUInt32 port);

	tUInt32 _id;
	string _name;
	
	string	_host;
	tUInt32 _port;

	tMemLevel _level;

	/**
	 * The udp sockaddr created with the _host and _port for the convinence to send voice data to.
	 */
	sockaddr_in* _sockaddr_in;

	/**
	 * The player to play back the voice data from the member
	 */
	AudioPlayer* _player;

	FileLog* _filelog;
};

#endif //__CHAT_MEMBER_HXX__